import React, { Dispatch } from 'react';

/** 定义管理页面上下文 */
export interface IManageContext {
  dispatch: Dispatch<any>;
  prefixCls: string;
  materialList: Record<string, any>[];
  materialTypeList: Record<string, any>[];
  cancelTypeList: Record<string, any>[];
  needInfo: Record<string, any>;
  locationProps?: Record<string, any>;
  pageRouterDomID: string;
  tableForm: any;
  nodesFlowListMemo: any;
  dataSource: Record<string, any>[];
  isView: boolean;
  BottomDataSource: Record<string, any>[];
  reloadInfoFunc: () => void;
  curRes: Record<string, any>;
  locationState: Record<string, any>;
}

/** 初始化管理页面上下文 */
const init_manage_context: IManageContext = {
  prefixCls: 'need-update-',
  dispatch: () => {},
  locationProps: {},
  needInfo: {},
  materialList: [],
  materialTypeList: [],
  cancelTypeList: [],
  pageRouterDomID: '',
  tableForm: '',
  nodesFlowListMemo: null,
  dataSource: [],
  isView: false,
  BottomDataSource: [],
  reloadInfoFunc: () => {},
  curRes: {},
  locationState: {},
};

/** 创建更新需求管理上下文 */
const NeedUpdateContext = React.createContext(init_manage_context);

export { NeedUpdateContext };
